package com.ruoyi.xh.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TablePageDataInfo;
import com.ruoyi.common.core.domain.CommentResult;
import com.ruoyi.xh.domain.XhRegionCar;
import com.ruoyi.xh.service.IXhRegionCarService;

/**
 * 物流车辆Controller
 *
 * @author songjw
 * @date 2024-12-13
 */
@Api(tags = "物流车辆Controller",value = "物流车辆Controller")
@RestController
@RequestMapping("/xh/regionCar")
public class XhRegionCarController extends BaseController {

    @Autowired
    private IXhRegionCarService xhRegionCarService;

    /**
     * 查询物流车辆列表
     */
    @PreAuthorize("@ss.hasPermi('xh:regionCar:list')")
    @GetMapping("/list")
    @ApiOperation("查询物流车辆列表")
    public TablePageDataInfo<XhRegionCar> list(XhRegionCar xhRegionCar) {
        return TablePageDataInfo.success(xhRegionCarService.selectXhRegionCarList(xhRegionCar));
    }

    /**
     * 获取物流车辆详细信息
     */
    @PreAuthorize("@ss.hasPermi('xh:regionCar:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取物流车辆详细信息")
    public CommentResult<XhRegionCar> getInfo(@PathVariable("id") Long id) {
        return CommentResult.success(xhRegionCarService.selectXhRegionCarById(id));
    }

    /**
     * 新增物流车辆
     */
    @PreAuthorize("@ss.hasPermi('xh:regionCar:add')")
    @Log(title = "物流车辆", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增物流车辆")
    public CommentResult<XhRegionCar> add(@RequestBody XhRegionCar xhRegionCar) {
            xhRegionCarService.insertXhRegionCar(xhRegionCar);
        return CommentResult.success();
    }

    /**
     * 修改物流车辆
     */
    @PreAuthorize("@ss.hasPermi('xh:regionCar:edit')")
    @Log(title = "物流车辆", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改物流车辆")
    public CommentResult<XhRegionCar> edit(@RequestBody XhRegionCar xhRegionCar) {
            xhRegionCarService.updateXhRegionCar(xhRegionCar);
        return CommentResult.success();
    }

    /**
     * 删除物流车辆
     */
    @PreAuthorize("@ss.hasPermi('xh:regionCar:remove')")
    @Log(title = "物流车辆", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除物流车辆")
    public CommentResult<XhRegionCar> remove(@PathVariable Long[] ids) {
            xhRegionCarService.deleteXhRegionCarByIds(ids);
        return CommentResult.success();
    }
}
